var m3_r = Math.floor(Math.random() * 99999999999);
var idleLogout = 30000;
var h_NickName = '';
var h_Charactor = '';
var h_GameID = '';
var userSession = '';
var loginInfo = {
    allowLogin: true,
    isSigned: false,
    loginUrl: "",
    logoutUrl: "",
    nickName: "",
    charactor: "",
    gameID: "",
    avatarUrl: "",
    settingUrl: "",
    profileUrl: "",
    time: 0
};
var intervalID = 0;
var rootProfile = 'http://profile.vtcgame.vn';
var rootAvatar = 'http://media.vtcgame.vn/avatar';

//var domain = "http://profile.vtcgame.vn/header";
var domain = "http://static.vtcgame.vn/header";
var ssoDomain = "https://id.vtc.vn/accounts/";

var mustConfirmPassURL = ['http://sandbox.vtcgame.vn/', 'http://vtcgame.vn/kiem-vcoin/', 'http://profile.vtcgame.vn/accounts/']; // ["http://vtcgame.vn/kiem-vcoin/"];

if (window.location.href.indexOf('http://game.vtc.vn/vuong-quoc-sao') >= 0) { window.location = 'http://vtcgame.vn/kiem-vcoin/vuong-quoc-sao/'; };
 

function ConfirmPass() {

    if (typeof (localStorage) == "undefined" || userSession == '') return;


    var isShowConfirm = false;
    for (var j = 0; j < mustConfirmPassURL.length; j++) {
        if (window.location.href.indexOf(mustConfirmPassURL[j]) == 0) {
            isShowConfirm = true;
        }
    }

    if (!isShowConfirm) return;
    if (window.localStorage.getItem(userSession) == null) return;

    if (window.localStorage.getItem(userSession) != null) {
        var info = JSON.parse(window.localStorage.getItem(userSession));

        if (new Date().getTime() - info.time < idleLogout * 60 ) {
            return;
            console.log('timeout');
        }


    }

    localStorage.clear();
    if (intervalID) clearInterval(intervalID);

    logoutHeader();
    /*
    //intervalID = window.setInterval(ConfirmPass, 1000);
    var setup_data = '<div><div id="popupwrap" style="width: 430px; left: 35%; top: 38%; z-index: 1999999999; position: fixed;">';
    setup_data += '<iframe  sandbox="allow-same-origin allow-scripts allow-popups allow-forms" frameborder="0" height="200px" width="410px" src="' + 'https://id.vtc.vn/accounts/Child.htm?v=1.02' + '"></iframe>';
    setup_data += '</div>';
    setup_data += '</div>';

    setup_data += ' <div id="overlayPopup" style="position: absolute; z-index: 9998; top: 0; left: 0;  width: 100%; height:100%;  display: block;  opacity: .80;  background: #ccc; filter: alpha(opacity=60);  -moz-opacity: 0.8;"></div>'
    $("#VcoinCheck_setup").remove();
    var h_div = document.createElement("div");
    h_div.setAttribute("id", "VcoinCheck_setup");
    h_div.setAttribute("style", " z-index: 99999999;");
    ps_appendBodyChild(h_div);
    $("#VcoinCheck_setup").html(setup_data);

    */

}

//if (intervalID) clearInterval(intervalID);
//intervalID = window.setInterval(ConfirmPass, 1000);

function VcoinCheck(event) {

    if (typeof (localStorage) == "undefined" || userSession == '') return;

    //if ( event.origin !== "http://javascript.info" )
    //  return

    // document.getElementById("test").innerHTML = "received: "+event.data
    // console.log(event.data); console.log(event.origin);

    if (event.data.toString().indexOf('PassConfirmSigout') >= 0) {
        //  sessionStorage.clear();
        window.localStorage.clear();
        logoutHeader();
        return;
        //window.location.href = loginInfo.logoutUrl.replace(/&amp;/g, "&");
    }

    if (event.data.toString().indexOf('ConfirmClick') >= 0) {

        loginInfo.time = new Date().getTime();

        //sessionStorage.setItem(userSession, JSON.stringify(loginInfo));
        window.localStorage.setItem(userSession, JSON.stringify(loginInfo));
        $("#VcoinCheck_setup").remove();

        setTimeout(function () {
            //  sessionStorage.clear();
            window.localStorage.clear();
            ConfirmPass();
        }, 60 * 30 * 1000);

        if (!loginInfo.isSigned) window.location.reload();

        if (intervalID) clearInterval(intervalID);
        intervalID = window.setInterval(ConfirmPass, 1000);

    }
}

if (window.addEventListener) {
    addEventListener("message", VcoinCheck, false);
} else {
    attachEvent("onmessage", VcoinCheck);
}


if (window.location.href.indexOf('http://localhost:12596') >= 0) { domain = "http://localhost:12596"; m3_r = 1 };

var enableClientSSO = true;
if (window.location.href.indexOf("http://cl.vtcgame.vn/") >= 0 || window.location.href.indexOf("http://vtcgame.vn/kiem-vcoin/") >= 0 ||
window.location.href.indexOf("http://au.vtcgame.vn/vipshop") >= 0 ||  window.location.href.indexOf("http://au.vtcgame.vn/auboutique") >= 0
) {
    enableClientSSO = true;
}

if (window.location.href.indexOf("http://diendan.vtcgame.vn/") >= 0 ) {
    enableClientSSO = false;
}


window.onSSOVTCIdLoad = function (session) {
    //  console.log(session);



    var ssoLoginInfor = {
        allowLogin: true,
        isSigned: false,
        loginUrl: "",
        logoutUrl: "",
        nickName: "",
        charactor: "",
        gameID: "",
        avatarUrl: "",
        settingUrl: "",
        profileUrl: ""
    };

    var mustLoginURL = ["http://cl.vtcgame.vn/",
        "http://profile.vtcgame.vn/",
        "http://profile.vtcgame.vn/",
        "http://vtcgame.vn/kiem-vcoin/",
		"http://cmo.vtcgame.vn/",
		"http://au.vtcgame.vn/vipshop",
		"http://au.vtcgame.vn/auboutique",
		"http://vtcgame.vn/hoanh",
    ];

    // Load chat when sso finish
 //  h_appendHeaderChild(domain + "/js/chat/portal.chat.js?ver=" + m3_r, "js");

    try {

        if (typeof (enableClientSSO) != "undefined" && enableClientSSO && typeof (readCookie) != "undefined" && typeof (Base64) != "undefined") {
            var chat_Nick = "";
            var chat_UserName = "";

            // string.Format("{0}avatarstorage/{1}/{2}/{3}_sqr.png", Config.MediaStoreUrl, prefixProfileNick, Config.ProfileNick, Config.ProfileNick);


            var ssosession = session; //readCookie("ssosession");

            if (typeof (ssosession) != "undefined" && ssosession == "") {

                if (typeof (localStorage) != "undefined") {
                    window.localStorage.clear();
                }

                if (loginInfo.isSigned && isValidURL(loginInfo.logoutUrl) && 
				 window.location.href.indexOf('cl.vtcgame.vn') < 0 &&
				 window.location.href.indexOf('http://localhost') < 0
				) {
                    window.location.href = loginInfo.logoutUrl.replace(/&amp;/g, "&");
                    return;
                }
                else {
                    h_BuildLogin(loginInfo);
                }
            }

            if (ssosession != null && ssosession.split('|').length > 2) {

                var profile = Base64.atob(ssosession.split('|')[0]);

                if (ssosession.split('|').length > 2) {

                    chat_Nick = profile.split('|')[0];
                    if (chat_Nick != "") {

                        nicname = chat_Nick;
                        ssoLoginInfor.nickName = chat_Nick;
                        ssoLoginInfor.allowLogin = true;
                        ssoLoginInfor.isSigned = true;
                        ssoLoginInfor.settingUrl = rootProfile + '/#ho-so/' + chat_Nick;
                        ssoLoginInfor.profileUrl = rootProfile + '/#home/' + chat_Nick;
                        ssoLoginInfor.avatarUrl = rootAvatar + "/avatarstorage/" + chat_Nick[0] + "/" + chat_Nick + "/" + chat_Nick + "_sqr.png";
                        ssoLoginInfor.logoutUrl = ssoDomain + "sso/logout/?ur=" + window.location.href;

                        userSession = chat_Nick;
                        if (isValidURL(loginInfo.logoutUrl)) ssoLoginInfor.logoutUrl = loginInfo.logoutUrl;

                    }
                }

                chat_UserName = Base64.atob(ssosession.split('|')[2]);

                if (loginInfo.isSigned && typeof (localStorage) != "undefined" && userSession != '' && window.localStorage.getItem(userSession) == null) {
                    try {
                        var isShowConfirm = false;
                        for (var j = 0; j < mustConfirmPassURL.length; j++) {
                            if (window.location.href.indexOf(mustConfirmPassURL[j]) == 0) {
                                isShowConfirm = true;
                            }
                        }

                        if (!isShowConfirm) return;

                        loginInfo.time = new Date().getTime();
                        window.localStorage.setItem(userSession, JSON.stringify(loginInfo));
                        $("#VcoinCheck_setup").remove();
                        if (intervalID) clearInterval(intervalID);
                        intervalID = window.setInterval(ConfirmPass, 1000);
                    } catch (err) { }
                }
                ConfirmPass();

                var re = new RegExp(/^\d+/); //starts with digit, one or more
                var m = re.exec(chat_Nick);

                if (chat_UserName != "" && m != null) {
                    ssoLoginInfor.avatarUrl = rootAvatar + "/avatarstorage/ping_header.png";
                    ssoLoginInfor.nickName = chat_UserName;
                }
                else {
                    loginInfo.nickName = chat_Nick;
                    if (loginInfo.isSigned) {
                        h_BuildLogin(ssoLoginInfor);
                        return;
                    }
                }

                for (var i = 0; i < mustLoginURL.length; i++) {
                    if (window.location.href.indexOf(mustLoginURL[i]) == 0) {

                        if (!loginInfo.isSigned && isValidURL(loginInfo.loginUrl)) {
						        window.location.href = loginInfo.loginUrl.replace(/&amp;/g, "&");
                                return;
								

                            var isShowConfirm = false;
                            for (var j = 0; j < mustConfirmPassURL.length; j++) {
                                if (window.location.href.indexOf(mustConfirmPassURL[j]) == 0) {
                                    isShowConfirm = true;
                                }
                            }


                            if (isShowConfirm && typeof (localStorage) != "undefined" &&
                            userSession != '' && window.localStorage.getItem(userSession) == null) {
                                ConfirmPass();
                                return;
                            }
                            else {
                                window.location.href = loginInfo.loginUrl.replace(/&amp;/g, "&");
                                return;
                            }

                            /*
						
                            for (var j = 0; j < mustConfirmPassURL.length; j++) {
                                if (window.location.href.indexOf(mustConfirmPassURL[j]) == 0) {
                                    ConfirmPass();
                                }
                                else {
                                    window.location.href = loginInfo.loginUrl.replace(/&amp;/g, "&");
                                }
                            }
							*/
                        }
					
					if( loginInfo.isSigned && loginInfo.nickName != ssoLoginInfor.nickName)
					{
						window.location.href = loginInfo.loginUrl.replace(/&amp;/g, "&");
					}

                        return true;
                    }
                }


                if (!loginInfo.isSigned || loginInfo.nickName != ssoLoginInfor.nickName)
                    h_BuildLogin(ssoLoginInfor);
            }

        }
    }
    catch (err) {
        console.log(err);
        console.log(err.stack)
    }


}

function isValidURL(url) {
    url = url.replace(/\//g, '');

    if (url.indexOf(document.domain.replace(/\//g, '')) == 0 || url.indexOf((document.location.protocol + "//" + document.location.hostname).replace(/\//g, '')) == 0 ||
         url.indexOf(ssoDomain.replace(/\//g, '')) == 0
        ) {
        return true;
    }
    return false;
}


var PassConfirmSigout = function (op, msg) {
    console.log('PassConfirmSigout');
}


function PassConfirmCheck(op, msg) {
    console.log('PassConfirmCheck');
}

function h_appendHeaderChild(url, type) {
    var fileref = "";
    if (type == "js") {
        fileref = document.createElement("script");
        fileref.setAttribute("type", "text/javascript");
        fileref.setAttribute("src", url);
    } else if (type == "css") {
        fileref = document.createElement("link");
        fileref.setAttribute("rel", "stylesheet");
        fileref.setAttribute("type", "text/css");
        fileref.setAttribute("href", url);
    }
    if (typeof fileref != "undefined")
        document.getElementsByTagName("head")[0].appendChild(fileref);
};

function h_appendBodyChild(element) {
    document.body.insertBefore(element, document.body.firstChild);
};

function h_GetStyle(rootUrl, currUrl) {
    var sRet = '';
    if (rootUrl.indexOf(currUrl) >= 0)
        sRet = 'class="h_chon"';
    return sRet;
}

var contentNotify = '';
function loadnotify() {
    var content = '';
    var url = 'http://vtcgame.vn/handler/newsheader.ashx';
    $.ajax({
        type: "GET",
        cache: false,
        url: url + '?' + Math.random(),
        processData: false,
        dataType: "jsonp",

        success: function (data) {
            if (typeof (data) !== "undefined" && data !== null) {
                content = '<a href="' + data.link + '" target="_blank">' + data.title + '</a>';
                $("#contentnotify").html(content);

            }
        },
        failure: function (msg) {

        }
    });


}

(function (a) {
    a.fn.h_BindData = function (d) {
        var c = {
            allowLogin: true,
            isSigned: false,
            loginUrl: "",
            logoutUrl: "",
            nickName: "",
            charactor: "",
            gameID: "",
            avatarUrl: "",
            settingUrl: "",
            profileUrl: ""
        };

        loginInfo = a.extend(c, d);

        // Load SSO after have input
     //   if (document.domain.indexOf("sandbox.vtcebank") >= 0 || document.domain.indexOf("localhost") >= 0) {
            // h_appendHeaderChild("http://sandbox.vtcebank.vn/accounts/sso/vtcidsso.min.js?ver=" + m3_r, "js");
    //    }
            //else if (document.domain.indexOf("sandbox.vtcgame.vn") >= 0)
            //{
            //h_appendHeaderChild("http://sandbox.vtcgame.vn/accounts/sso/vtcidsso.min.js?ver=" + m3_r, "js");
            //	}
     //   else {
            h_appendHeaderChild("https://id.vtc.vn/accounts/sso/vtcidsso.min.js?ver=" + m3_r, "js");
     //   }

        var sessionInfor = readCookieSession("ssosession");

        var bx = getSessionInfo(sessionInfor);
		
						
	//	if( bx != null && d.isSigned && d.nickName != bx.nickName)
	//	{
	//		window.location.href = loginInfo.loginUrl.replace(/&amp;/g, "&");
	//	}
					
        if (bx != null) {
            h_BuildLogin(bx);
        }
        else {

            h_BuildLogin(loginInfo);
        }
    };
})(jQuery);

h_appendHeaderChild(domain + "/js/chat/portal.chat.common.js?ver=" + m3_r, "js");
h_appendHeaderChild(domain + "/css/header_font.css?ver=" + m3_r, "css");
h_appendHeaderChild(domain + "/css/header_xanh.css?ver=" + m3_r, "css");
h_appendHeaderChild(domain + "/css/chat.css?ver=" + m3_r, "css");

h_appendHeaderChild(domain + "/js/Vendor/flexcroll.min.js?ver=" + m3_r, "js");
//h_appendHeaderChild(domain + "/js/Vendor/jquery.signalR-2.0.0-rc1.js", "js");
//h_appendHeaderChild(domain + "/js/Vendor/ModalPopupWindow.js", "js");
//h_appendHeaderChild("http://profile.vtcgame.vn/setup/scripts//profilesetup.js", "js");

// banner
//if(document.domain.indexOf("fifaonline") >=0 || document.domain.indexOf("wot")>=0){
h_appendHeaderChild("http://event.vtcgame.vn/menu/js/menuvtcgame.js?ver=" + m3_r, "js");
/*if (window.location.href.indexOf('vtcgame.vn/kiem-vcoin/') >= 0 && window.location.href.indexOf('http://vtcgame.vn/kiem-vcoin/li-xi-phat-loc/') < 0) {
    h_appendHeaderChild("http://ebank.vtc.vn/WebLixi/Scripts/Lixi.js?ver=" + m3_r, "js");
}*/
//h_appendHeaderChild("http://static.vtcgame.vn/header/popupTem.js?ver=" + m3_r, "js");


//}
/*
if (window.location.href.indexOf('vtcgame.vn/kiem-vcoin/') >= 0 && window.location.href.indexOf('vtcgame.vn/kiem-vcoin/vuong-quoc-sao/') < 0 ) {
	h_appendHeaderChild("http://static.vtcgame.vn/header/popupTem.js?ver=" + m3_r, "js");
}
if (window.location.href.indexOf('vtcgame.vn/kiem-vcoin/vuong-quoc-sao/') >= 0) {
	h_appendHeaderChild("http://static.vtcgame.vn/header/popupTemAUCF.js?ver=" + m3_r, "js");
}*/

//console.log(window.location.href);

/*if (window.location.href == 'http://au.vtcgame.vn/' ||
	window.location.href == 'http://cf.vtcgame.vn/' ||
	window.location.href == 'http://hc.vtcgame.vn/' ||
	window.location.href == 'http://a2.vtcgame.vn/' ||
	window.location.href == 'http://phidoi.vtcgame.vn/' ||
	window.location.href == 'http://bongro.vtcgame.vn/') {
	h_appendHeaderChild("http://static.vtcgame.vn/header/popupSNAU.js?ver=" + m3_r, "js");
}*/

/*
if (window.location.href.indexOf('ghk.vtcgame.vn') >= 0 || window.location.href.indexOf('bongro.vtcgame.vn') >= 0) {
	h_appendHeaderChild("http://static.vtcgame.vn/header/popupTemPD.js?ver=" + m3_r, "js");
}
if (window.location.href.indexOf('cmo.vtcgame.vn') >= 0 || window.location.href.indexOf('a2.vtcgame.vn') >= 0) {
	h_appendHeaderChild("http://static.vtcgame.vn/header/popupTemPD.js?ver=" + m3_r, "js");
}
if (window.location.href.indexOf('cl.vtcgame.vn') >= 0 || window.location.href.indexOf('cf.vtcgame.vn') >= 0 || window.location.href.indexOf('diendan.vtcgame.vn') >= 0) {
	h_appendHeaderChild("http://static.vtcgame.vn/header/popupTemPD.js?ver=" + m3_r, "js");
}
*/
var readCookieSession = function (name) {
    var nameEQ = escape(name) + "=";
    var ca = document.cookie.split(';');
    for (var i = 0; i < ca.length; i++) {
        var c = ca[i];
        while (c.charAt(0) == ' ') c = c.substring(1, c.length);
        if (c.indexOf(nameEQ) == 0) return unescape(c.substring(nameEQ.length, c.length));
    }
    return "";
};

var getSessionInfo = function (ssosession) {
    var ssoLoginInfor = {
        allowLogin: true,
        isSigned: false,
        loginUrl: "",
        logoutUrl: "",
        nickName: "",
        charactor: "",
        gameID: "",
        avatarUrl: "",
        settingUrl: "",
        profileUrl: ""
    };

    if (typeof (window.atob) == "undefined") return null;

    try {

        var chat_Nick = "";
        var chat_UserName = "";
        if (typeof (ssosession) != "undefined" && ssosession == "") {
            return null;
        }

        if (ssosession != null && ssosession.split('|').length > 2) {

            var profile = window.atob(ssosession.split('|')[0]);

            if (ssosession.split('|').length > 2) {
                chat_Nick = profile.split('|')[0];
                if (chat_Nick != "") {

                    nicname = chat_Nick;
                    ssoLoginInfor.nickName = chat_Nick;
                    ssoLoginInfor.allowLogin = true;
                    ssoLoginInfor.isSigned = true;
                    ssoLoginInfor.settingUrl = rootProfile + '/#ho-so/' + chat_Nick;
                    ssoLoginInfor.profileUrl = rootProfile + '/#home/' + chat_Nick;
                    ssoLoginInfor.avatarUrl = rootAvatar + "/avatarstorage/" + chat_Nick[0] + "/" + chat_Nick + "/" + chat_Nick + "_sqr.png";
                    ssoLoginInfor.logoutUrl = ssoDomain + "sso/logout/?ur=" + window.location.href;

                    if (isValidURL(loginInfo.logoutUrl)) ssoLoginInfor.logoutUrl = loginInfo.logoutUrl;

                }
            }

            chat_UserName = window.atob(ssosession.split('|')[2]);
			
		if( enableClientSSO && loginInfo.isSigned && loginInfo.nickName != chat_UserName && loginInfo.nickName != chat_Nick && chat_UserName != "" && loginInfo.nickName != "" )
	 	{
	 		window.location.href = loginInfo.loginUrl.replace(/&amp;/g, "&");
	 	}
	

            var re = new RegExp(/^\d+/); //starts with digit, one or more
            var m = re.exec(chat_Nick);

            if (chat_UserName != "" && m != null) {
                ssoLoginInfor.avatarUrl = rootAvatar + "/avatarstorage/ping_header.png";
                ssoLoginInfor.nickName = chat_UserName;
            }
            else {
                loginInfo.nickName = chat_Nick;
            }


        }
        else {
            return null;
        }

    }
    catch (err) {
        console.log(err);
        console.log(err.stack)
    }

    return ssoLoginInfor;
}

function h_BuildLogin(b) {

    if (b.allowLogin == true) {
        h_GameID = b.gameID;
        if (b.isSigned == true) {
            h_NickName = b.nickName;
            h_Charactor = b.charactor;
            $('.h_acc').html('<div class="h_acc_img"><img src="' + b.avatarUrl + '" border="0" /></div><div class="h_acc_text"><a href="' + b.profileUrl + '" id="a_signed">' + b.nickName + '</a></div>');
            $('.h_acc_down').html('<ul><li class="h_ic2"><a  href="' + b.profileUrl + '">Trang cĂ¡ nhĂ¢n</a></li><li class="h_ic1"><a href="' + b.settingUrl + '">CĂ i Ä‘áº·t cĂ¡ nhĂ¢n</a></li><li class="h_ic3"><a id="logoutHeader"  href="javascript:void(0);' + '">ÄÄƒng xuáº¥t</a></li></ul>');
            $('#a_signed').hover(function () {
                $('.h_acc_down').fadeIn();
            }, function () {
            });
        } else {
            $('.h_acc').html('<div class="h_acc"><p><a href="' + b.loginUrl + '"><span>ÄÄƒng nháº­p</span></a> &nbsp; | &nbsp; <a id="btnHeaderVtcReg" href="https://id.vtc.vn/home/dang-ky-tai-khoan.html"><span>ÄÄƒng kĂ½</span></a></p></div>');
            $('.h_acc_down').hide();
        }
    } else {
        $('.h_acc').width(60);
        $('.h_dong1 marquee').width(695);
        $('.h_acc').html('<p><a id="btnHeaderVtcReg" href="https://id.vtc.vn/home/dang-ky-tai-khoan.html">ÄÄƒng kĂ½</a></p>');
        $('.h_acc_down').hide();
    }

    $('#logoutHeader').on('click', logoutHeader);
	$('#btnHeaderVtcReg').on('click', function(){
		if (typeof (ga) == 'undefined') {
			(function (i, s, o, g, r, a, m) {
				i['GoogleAnalyticsObject'] = r; i[r] = i[r] || function () {
				(i[r].q = i[r].q || []).push(arguments)
				}, i[r].l = 1 * new Date(); a = s.createElement(o),
				m = s.getElementsByTagName(o)[0]; a.async = 1; a.src = g; m.parentNode.insertBefore(a, m)
			})(window, document, 'script', '//www.google-analytics.com/analytics.js', 'ga');
		}	
		ga('create', GA_UA, 'vtcgame.vn');
		ga('send', 'event', 'Register', 'click', 'Register Main Header');
	});
}

var logoutHeader = function () {

    var date = new Date();
    date.setTime(date.getTime() + (-30 * 24 * 60 * 60 * 1000));

    var expires = ";expires=" + date.toGMTString();
    var currentSSOdomain = document.domain.split('.').length > 2 ? document.domain.substr(document.domain.indexOf('.')) : '.' + document.domain;
    document.cookie = "ssosession" + "=" + "" + ";domain=" + currentSSOdomain + ";path=/" + expires;
    document.cookie = "ssoinfo" + "=" + "" + ";domain=" + currentSSOdomain + ";path=/" + expires;

    if (typeof (localStorage) != "undefined") localStorage.clear();
    if (intervalID) clearInterval(intervalID);
    //    window.location.href = loginInfo.logoutUrl; 

    window.location.href = 'https://id.vtc.vn/accounts/sso/logout/?ur=' + encodeURIComponent(loginInfo.logoutUrl);
}

$(document).ready(function () {

    var h_currUrl = window.location.href;
	if( window.location.href.indexOf('vtc.com/') > 0) return;
    var h_link = '';
    var h_data = '<div class="h_header"><div class="h_page h_menu_down"><div class="h_menu"><div class="h_dong2">';
    //var h_data = '<div class="h_header"><div class="h_page h_menu_down"><div class="h_logo"><a href="http://vtcgame.vn/intro.html"><img src="http://static.vtcgame.vn/header/images/logo.gif" border="0" /></a></div><div class="h_menu"><div class="h_dong1">';
    //h_data += '<marquee scrollamount="3" id="contentnotify">';

    //h_data += '</marquee>';
    //h_data += '<div class="h_acc"></div></div><div class="h_dong2">';
    h_data += '<ul>';
    h_data += '<li><a class="h_chon" ' + h_GetStyle(h_currUrl, 'vtcgame.vn/games') + ' href="http://vtcgame.vn/games" id="game">Game</a></li>';
    h_data += '<li><a ' + h_GetStyle(h_currUrl, 'vtcgame.vn/tin-tuc') + ' href="http://vtcgame.vn/tin-tuc">Tin tá»©c</a></li>';
    h_data += '<li><a ' + h_GetStyle(h_currUrl, 'vtcgame.vn/e-sports') + ' href="http://esportsviet.vn/">e-Sports</a><img width="18" height="7" style="float: right;margin-top: 0px;margin-left: -10px;" src="http://static.vtcgame.vn/header/images/gif-0236.gif"></li>';
    h_data += '<li><a ' + h_GetStyle(h_currUrl, 'vtcgame.vn/hotro') + ' href="http://vtcgame.vn/hotro">Há»— trá»£</a></li>';
	
	/*Danh sach dien dan tuong ung voi tung game*/
	

    /*
    Tháº­p Nhá»‹ tranh tĂ i http://vtcgame.vn/kiem-vcoin/thap-nhi-tranh-tai/ : http://www.go.vn/diendan/forumdisplay.php?1245-Thao-Luan-Chung
    SÄƒn ngá»c    http://vtcgame.vn/kiem-vcoin/san-ngoc/: http://www.go.vn/diendan/forumdisplay.php?1245-Thao-Luan-Chung
    Lá»¥c cá»‘c Ä‘Ă o tiá»n http://vtcgame.vn/kiem-vcoin/luc-coc-dao-tien/ : http://www.go.vn/diendan/forumdisplay.php?1245-Thao-Luan-Chung
    Lá»‡nh truy nĂ£ http://vtcgame.vn/kiem-vcoin/lenh-truy-na/ : http://www.go.vn/diendan/forumdisplay.php?1244-Le-nh-Truy-Na-Ban-quai-thuong-Vcoin
    Máº­t mĂ£ Maya http://vtcgame.vn/kiem-vcoin/mat-ma-maya/ : http://www.go.vn/diendan/forumdisplay.php?1365-Mat-ma-May-a
    CĂ¡ thá»§ siĂªu Ä‘Äƒng: http://www.go.vn/diendan/forumdisplay.php?1257-Ca-thu-sieu-dang
    VÆ°Æ¡ng Quá»‘c Sao http://vtcgame.vn/kiem-vcoin/vuong-quoc-sao/: www.go.vn/diendan/forumdisplay.php?1305-Vuong-Quoc-Sao
    CĂ¡ kiáº¿m http://vtcgame.vn/kiem-vcoin/ca-kiem/: http://www.go.vn/diendan/forumdisplay.php?1020-Ca-Kiem

     */
	h_link = '#';
    var domainDiendan = 'http://diendan.vtcgame.vn';// 'http://diendan.game.go.vn'; // http://diendan.vtcgame.vn
    var domainGo = 'http://diendan.vtcgame.vn';//'http://www.go.vn/diendan'; // 

    if (h_currUrl.indexOf("http://vtcgame.vn/kiem-vcoin/thap-nhi-tranh-tai/") >= 0)
        h_link = domainDiendan + '/forumdisplay.php?1063-TNTT-San-Ngoc-Luc-Coc-Dao-Tien';
    else
        if (h_currUrl.indexOf("http://vtcgame.vn/kiem-vcoin/san-ngoc/") >= 0)
            h_link = domainDiendan + '/forumdisplay.php?1063-TNTT-San-Ngoc-Luc-Coc-Dao-Tien';
        else
            if (h_currUrl.indexOf("http://vtcgame.vn/kiem-vcoin/luc-coc-dao-tien/") >= 0)
                h_link = domainDiendan + '/forumdisplay.php?1063-TNTT-San-Ngoc-Luc-Coc-Dao-Tien';
            else
                if (h_currUrl.indexOf("http://vtcgame.vn/kiem-vcoin/lenh-truy-na/") >= 0)
                    h_link = domainDiendan + '/forumdisplay.php?1062-Le-nh-Truy-Na-Ban-quai-thuong-Vcoin';
                else
                    if (h_currUrl.indexOf("http://vtcgame.vn/kiem-vcoin/mat-ma-maya/") >= 0)
                        h_link = domainDiendan + '/forumdisplay.php?1064-Mat-ma-May-a';
                    else
                        if (h_currUrl.indexOf("http://vtcgame.vn/kiem-vcoin/Ca-thu-sieu-dang/") >= 0)
                            h_link = domainDiendan + '/forumdisplay.php?1065-Ca-thu-sieu-dang';
                        else

                            if (h_currUrl.indexOf("http://vtcgame.vn/kiem-vcoin/vuong-quoc-sao/") >= 0)
                                h_link = domainDiendan + '/forumdisplay.php?1066-Vuong-Quoc-Sao';
                            else
                                if (h_currUrl.indexOf("http://vtcgame.vn/kiem-vcoin/ca-kiem/") >= 0)
                                    h_link = domainDiendan + '/forumdisplay.php?1067-Ca-Kiem';
                                else
                                    if (h_currUrl.indexOf("a2.vtcgame.vn") >= 0)
                                        h_link = domainDiendan + '/forumdisplay.php?248';
                                    else
                                        if (h_currUrl.indexOf("au.vtcgame.vn") >= 0)
                                            h_link = domainDiendan + '/forumdisplay.php?239';

                                        else
                                            if (h_currUrl.indexOf("bongro.vtcgame.vn") >= 0)
                                                h_link = domainDiendan + '/forumdisplay.php?90';

                                            else
                                                if (h_currUrl.indexOf("fifaonline.vtcgame.vn") >= 0)
                                                    h_link = domainDiendan + '/forumdisplay.php?242';

                                                else
                                                    if (h_currUrl.indexOf("wot.vtcgame.vn") >= 0)
                                                        h_link = domainDiendan + '/forumdisplay.php?330';

                                                    else
                                                        if (h_currUrl.indexOf("phidoi.vtcgame.vn") >= 0)
                                                            h_link = domainDiendan + '/forumdisplay.php?244';

                                                        else
                                                            if (h_currUrl.indexOf("cl.vtcgame.vn") >= 0)
                                                                h_link = domainDiendan + '/forumdisplay.php?1034';

                                                            else
                                                                if (h_currUrl.indexOf("cf.vtcgame.vn") >= 0)
                                                                    h_link = domainDiendan + '/forumdisplay.php?241';
                                                                else
                                                                    if (h_currUrl.indexOf("cmo.vtcgame.vn") >= 0)
                                                                        h_link = domainDiendan + '/forumdisplay.php?1048';
																	else
																		if (h_currUrl.indexOf("http://vtcgame.vn/kiem-vcoin/tai-loc/") >= 0)
																			h_link = domainDiendan + '/forumdisplay.php?1071-Tai-Loc-Game-Roulette-kiem-trieu-Vcoin-dinh-cao';
																		else
																			if (h_currUrl.indexOf("http://vtcgame.vn/hoanh/") >= 0)
																				h_link = domainDiendan + '/forumdisplay.php?1112-Hoanh-Tao-Thien-Ha';
																			else
																				if (h_currUrl.indexOf("http://hc.vtcgame.vn/") >= 0)
																					h_link = domainDiendan + '/forumdisplay.php?203-Huyet-Chien';
																				else
																					h_link = domainDiendan + '/forum.php';
																				
	
	
    h_data += '<li><a href="' + h_link + '" id="cong-dong">Cá»™ng Ä‘á»“ng</a></li>';
	/*End cong dong*/
	
    // h_data += '<li><a href="javascript:;" id="gift-code">Gift Code</a></li>';
    h_data += '<li><a ' + h_GetStyle(h_currUrl, 'vtcgame.vn/gift-code') + ' href="http://vtcgame.vn/gift-code">Gift Code</a></li>';
    h_data += '<li><a ' + h_GetStyle(h_currUrl, 'id.vtc.vn/eshop/nap-vcoin/nap-vcoin-qua-the-cao.html') + ' href="https://id.vtc.vn/eshop/nap-vcoin/nap-vcoin-qua-the-cao.html" target="_blank">Náº¡p VCoin</a></li>';
    /*   h_data += '<li><input type="search" id="h_search" placeholder="TĂ¬m kiáº¿m"></li>'; */
    h_data += '</ul>';
    /*Preview Info*/
    h_data += '</div>';
    h_data += '<div class="h_acc_down"></div><div class="h_menu_list"><div class="h_menu_list2 game"><div class="h_menu_list_preview">';
    h_data += '<div class="h_menu_list_t hc" ><img src="http://static.vtcgame.vn/header/images/huyetchien.jpg" /><h3>Huyáº¿t chiáº¿n</h3><h5></h5><div class="clear"></div></div>';
	h_data += '<div class="h_menu_list_t a2" style="display:block;"><img src="http://static.vtcgame.vn/header/images/au2.jpg" /><h3>Audition 2</h3><h5></h5><div class="clear"></div></div>';
    h_data += '<div class="h_menu_list_t au" ><img src="http://static.vtcgame.vn/header/images/au1.jpg" /><h3>New Audition</h3><h5></h5><div class="clear"></div></div>';
    h_data += '<div class="h_menu_list_t cf" ><img src="http://static.vtcgame.vn/header/images/cf.jpg" /><h3>Äá»™t KĂ­ch</h3><h5></h5><div class="clear"></div></div>';
    //h_data += '<div class="h_menu_list_t ffol2" ><img src="http://static.vtcgame.vn/header/images/fifa.jpg" /><h3>Fifa Online 2</h3><h5></h5><div class="clear"></div></div>';
    h_data += '<div class="h_menu_list_t phi-doi" ><img src="http://static.vtcgame.vn/header/images/phidoi.jpg" /><h3>Phi Äá»™i</h3><h5></h5><div class="clear"></div></div>';
    h_data += '<div class="h_menu_list_t vbr" ><img src="http://static.vtcgame.vn/header/images/vbr.jpg" /><h3>Vua BĂ³ng Rá»•</h3><h5></h5><div class="clear"></div></div>';
	h_data += '<div class="h_menu_list_t gogorun" ><img src="http://static.vtcgame.vn/header/images/gogorun.jpg" /><h3>GoGoRun</h3><h5></h5><div class="clear"></div></div>';
	h_data += '<div class="h_menu_list_t lovebeat" ><img src="http://static.vtcgame.vn/header/images/lovebeat.gif" /><h3>Love Beat</h3><h5></h5><div class="clear"></div></div>';
    //h_data += '<div class="h_menu_list_t wot" ><img src="http://static.vtcgame.vn/header/images/wot.jpg" /><h3>World of Tanks</h3><h5></h5><div class="clear"></div></div>';
    
	
	//h_data += '<div class="h_menu_list_t ninja" ><img src="http://static.vtcgame.vn/header/images/ninja.jpg" /><h3>Ninja</h3><h5></h5><div class="clear"></div></div>';
    //h_data += '<div class="h_menu_list_t than-chien" ><img src="http://static.vtcgame.vn/header/images/tc.jpg" /><h3>Tháº§n Chiáº¿n</h3><h5></h5><div class="clear"></div></div>';
    //h_data += '<div class="h_menu_list_t cmo" ><img src="http://static.vtcgame.vn/header/images/cmo3.jpg" /><h3>ChuyĂªn Gia BĂ³ng ÄĂ¡</h3><h5></h5><div class="clear"></div></div>';
	h_data += '<div class="h_menu_list_t gianghoky" ><img src="http://static.vtcgame.vn/header/images/ghk.png" /><h3>Giang Há»“ KĂ½</h3><h5></h5><div class="clear"></div></div>';
	h_data += '<div class="h_menu_list_t hoanhtao" ><img src="http://static.vtcgame.vn/header/images/hoanhtao.png" /><h3>HoĂ nh Táº£o ThiĂªn Háº¡</h3><h5></h5><div class="clear"></div></div>';
	h_data += '<div class="h_menu_list_t satthu" ><img src="http://static.vtcgame.vn/header/images/satthu.jpg" /><h3>SĂ¡t Thá»§ Truyá»n Ká»³</h3><h5></h5><div class="clear"></div></div>';
	h_data += '<div class="h_menu_list_t cotyphu" ><img src="http://static.vtcgame.vn/header/images/cotyphu.png" /><h3>Cá» Tá»· PhĂº</h3><h5></h5><div class="clear"></div></div>';
	h_data += '<div class="h_menu_list_t amhac" ><img src="http://static.vtcgame.vn/header/images/amhactamquco.jpg" /><h3>Ăm Háº¯c Tam Quá»‘c</h3><h5></h5><div class="clear"></div></div>';
	
	h_data += '<div class="h_menu_list_t sieu-cup" ><img src="http://static.vtcgame.vn/header/images/Sieucup215x125.jpg" /><h3>SiĂªu cĂºp</h3><h5></h5><div class="clear"></div></div>';
	h_data += '<div class="h_menu_list_t tam-loc" ><img src="http://static.vtcgame.vn/header/images/tamloc_215x125.png" /><h3>Tam lá»™c</h3><h5></h5><div class="clear"></div></div>';
	h_data += '<div class="h_menu_list_t san-thuong" ><img src="http://static.vtcgame.vn/header/images/san-thuong215x125.jpg" /><h3>SÄƒn thÆ°á»Ÿng</h3><h5></h5><div class="clear"></div></div>';
	h_data += '<div class="h_menu_list_t that-truyen" ><img src="http://static.vtcgame.vn/header/images/that-truyen-215-125.png" /><h3>Tháº¥t truyá»n</h3><h5></h5><div class="clear"></div></div>';
    h_data += '<div class="h_menu_list_t thap-nhi-tranh-tai" ><img src="http://static.vtcgame.vn/header/images/tntt.jpg" /><h3>Tháº­p Nhá»‹ Tranh TĂ i</h3><h5></h5><div class="clear"></div></div>';
    h_data += '<div class="h_menu_list_t vuong-quoc-sao" ><img src="http://static.vtcgame.vn/header/images/vqsao.png" /><h3>VÆ°Æ¡ng Quá»‘c Sao</h3><h5></h5><div class="clear"></div></div>';

    //h_data += '<div class="h_menu_list_t lenh-truy-na" ><img src="http://static.vtcgame.vn/header/images/LENHTRUYNA.png" /><h3>Lá»‡nh Truy NĂ£</h3><h5></h5><div class="clear"></div></div>';
    //h_data += '<div class="h_menu_list_t mat-ma-maya" ><img src="http://static.vtcgame.vn/header/images/maya.png" /><h3>Máº­t MĂ£ Maya</h3><h5></h5><div class="clear"></div></div>';
  //  h_data += '<div class="h_menu_list_t luc-coc" ><img src="http://static.vtcgame.vn/header/images/LucCocDaoTien.png" /><h3>Lá»¥c Cá»‘c Äà€o TiĂªn</h3><h5></h5><div class="clear"></div></div>';
    h_data += '<div class="h_menu_list_t clt" ><img src="http://static.vtcgame.vn/header/images/cltlogo.png" /><h3>Cá»­u Long Triá»u</h3><h5></h5><div class="clear"></div></div>';
    //h_data += '<div class="h_menu_list_t ca-kiem" ><img src="http://static.vtcgame.vn/header/images/ca-kiem.jpg" /><h3>Cà KiĂª̀m</h3><h5></h5><div class="clear"></div></div>';
    h_data += '<div class="h_menu_list_t san-ngoc" ><img src="http://static.vtcgame.vn/header/images/san-ngoc.png" /><h3>SÄƒn Ngò£c</h3><h5></h5><div class="clear"></div></div>';
  
    h_data += '<div class="h_menu_list_t nha-may-keo-ngot" ><img src="http://static.vtcgame.vn/header/images/keongot.jpg" /><h3>NhĂ  MĂ¡y Káº¹o Ngá»t</h3><h5></h5><div class="clear"></div></div>';
	
	h_data += '<div class="h_menu_list_t audition-mobile" ><img src="http://static.vtcgame.vn/header/images/aumobile.png" /><h3>Au Mobile</h3><h5></h5><div class="clear"></div></div>';
	h_data += '<div class="h_menu_list_t lolem-mobile" ><img src="http://static.vtcgame.vn/header/images/lolemmobile.jpg" /><h3>Lá» lem</h3><h5></h5><div class="clear"></div></div>';
    h_data += '<div class="h_menu_list_t phi-ma-mobile" ><img src="http://static.vtcgame.vn/header/images/phima.jpg" /><h3>Phi MĂ£</h3><h5></h5><div class="clear"></div></div>';
	h_data += '<div class="h_menu_list_t temphepthuat-mobile" ><img src="http://static.vtcgame.vn/header/images/temphepthuat.jpg" /><h3>Tem PhĂ©p Thuáº­t</h3><h5></h5><div class="clear"></div></div>';
	h_data += '<div class="h_menu_list_t dao-mo" ><img src="http://static.vtcgame.vn/header/images/daomo.jpg" /><h3>ÄĂ o má»</h3><h5></h5><div class="clear"></div></div>';
	//h_data += '<div class="h_menu_list_t lat-ngua" ><img src="http://static.vtcgame.vn/header/images/latngua.jpg" /><h3>Láº­t ngá»­a</h3><h5></h5><div class="clear"></div></div>';
	h_data += '<div class="h_menu_list_t cungthu" ><img src="http://static.vtcgame.vn/header/images/cungthu_215x125.jpg" /><h3>Cung Thá»§</h3><h5></h5><div class="clear"></div></div>';
	//h_data += '<div class="h_menu_list_t bingo" ><img src="http://static.vtcgame.vn/header/images/bingo_215x125.jpg" /><h3>BĂ­ NgĂ´ </h3><h5></h5><div class="clear"></div></div>';
	h_data += '<div class="h_menu_list_t san-ngoc-mobile" ><img src="http://static.vtcgame.vn/header/images/sanngoc_mobile.png" /><h3>SÄƒn ngá»c </h3><h5></h5><div class="clear"></div></div>';
	h_data += '</div>';
    /*End Preview Info*/
    /*List game*/
    h_data += '<div class="h_menu_list_nd"><p>GAME CLIENT</p>';

    h_data += '<div class="h_menu_p"  id="hc"><a href="http://hc.vtcgame.vn"><img src="http://static.vtcgame.vn/header/images/ic_t.gif" title="Táº£i vá»" border="0" /></a><a href="http://hc.vtcgame.vn/?utm_source=conggame&utm_medium=banner&utm_campaign=huyetchien">Huyáº¿t Chiáº¿n<img width="18" height="7" style="float: right;margin-top: 0px; margin-right: 40px;" src="http://static.vtcgame.vn/header/images/gif-0236.gif"></a><div class="clear"></div></div>';
	h_data += '<div class="h_menu_p"  id="au"><a href="http://vtcgame.vn/download-games/2"><img src="http://static.vtcgame.vn/header/images/ic_t.gif" title="Táº£i vá»" border="0" /></a><a href="http://au.vtcgame.vn">New Audition</a><div class="clear"></div></div>';
    h_data += '<div class="h_menu_p"  id="a2"><a href="http://vtcgame.vn/download-games/13"><img src="http://static.vtcgame.vn/header/images/ic_t.gif" title="Táº£i vá»" border="0" /></a><a href="http://a2.vtcgame.vn">Audition 2</a><div class="clear"></div></div>';
    h_data += '<div class="h_menu_p"  id="cf"><a href="http://vtcgame.vn/download-games/1"><img src="http://static.vtcgame.vn/header/images/ic_t.gif" title="Táº£i vá»" border="0" /></a><a href="http://cf.vtcgame.vn/">Äá»™t KĂ­ch</a><div class="clear"></div></div>';
    //h_data += '<div class="h_menu_p"  id="ffol2"><a href="http://vtcgame.vn/download-games/3"><img src="http://static.vtcgame.vn/header/images/ic_t.gif" title="Táº£i vá»" border="0" /></a><a href="http://fifaonline.vtcgame.vn">Fifa Online 2</a><div class="clear"></div></div>';

    h_data += '<div class="h_menu_p"  id="phi-doi"><a href="http://vtcgame.vn/download-games/4"><img src="http://static.vtcgame.vn/header/images/ic_t.gif" title="Táº£i vá»" border="0" /></a><a href="http://phidoi.vtcgame.vn">Phi Äá»™i</a><div class="clear"></div></div>';
    h_data += '<div class="h_menu_p"  id="vbr"><a href="http://vtcgame.vn/download-games/22"><img src="http://static.vtcgame.vn/header/images/ic_t.gif" title="Táº£i vá»" border="0" /></a><a href="http://bongro.vtcgame.vn">Vua BĂ³ng Rá»•</a><div class="clear"></div></div>';
	h_data += '<div class="h_menu_p"  id="gogorun"><a href="http://run.vtcgame.vn/download/full-version.php"><img src="http://static.vtcgame.vn/header/images/ic_t.gif" title="Táº£i vá»" border="0" /></a><a href="http://run.vtcgame.vn">GoGoRun<img width="18" height="7" style="float: right;margin-top: 0px; margin-right: 40px;" src="http://static.vtcgame.vn/header/images/gif-0236.gif"></a><div class="clear"></div></div>';
	h_data += '<div class="h_menu_p"  id="lovebeat"><a href="http://lovebeat.vtcgame.vn/"><img src="http://static.vtcgame.vn/header/images/ic_t.gif" title="Táº£i vá»" border="0" /></a><a href="http://lovebeat.vtcgame.vn/">Love Beat<img width="18" height="7" style="float: right;margin-top: 0px; margin-right: 40px;" src="http://static.vtcgame.vn/header/images/gif-0236.gif"></a><div class="clear"></div></div>';
    //h_data += '<div class="h_menu_p"  id="wot"><a href="http://vtcgame.vn/download-games/16"><img src="http://static.vtcgame.vn/header/images/ic_t.gif" title="Táº£i vá»" border="0" /></a><a href="http://wot.vtcgame.vn">World of Tanks</a><div class="clear"></div></div>';
	
	
    h_data += '</div>';
    h_data += '<div class="h_menu_list_nd"><p>WEB GAME</p>';
h_data += '<div class="h_menu_p"  id="amhac"><a href="http://vtcgame.vn/amhac/"><img src="http://static.vtcgame.vn/header/images/ic_c.gif" title="ChÆ¡i ngay" border="0" /></a><a href="http://vtcgame.vn/amhac/">Ăm Háº¯c Tam Quá»‘c</a><img width="18" height="7" style="float: right;margin-top: 0px; margin-right: 10px;" src="http://static.vtcgame.vn/header/images/gif-0236.gif"></a><div class="clear"></div></div>';
	h_data += '<div class="h_menu_p"  id="gianghoky"><a href="http://gianghoky.vn"><img src="http://static.vtcgame.vn/header/images/ic_c.gif" title="ChÆ¡i ngay" border="0" /></a><a href="http://gianghoky.vn">Giang Há»“ KĂ½<img width="18" height="7" style="float: right;margin-top: 0px; margin-right: 40px;" src="http://static.vtcgame.vn/header/images/gif-0236.gif"></a><div class="clear"></div></div>';
    //h_data += '<div class="h_menu_p"  id="clt"><a href="http://cl.vtcgame.vn/Home/ListServer"><img src="http://static.vtcgame.vn/header/images/ic_c.gif" title="ChÆ¡i ngay" border="0" /></a><a href="http://cl.vtcgame.vn">Cá»­u Long Triá»u</a><div class="clear"></div></div>';

    //h_data += '<div class="h_menu_p"  id="cmo"><a href="http://cmo.vtcgame.vn/server.html"><img src="http://static.vtcgame.vn/header/images/ic_c.gif" title="ChÆ¡i ngay" border="0" /></a><a href="http://cmo.vtcgame.vn/">ChuyĂªn Gia BĂ³ng ÄĂ¡</a><div class="clear"></div></div>';
	h_data += '<div class="h_menu_p"  id="hoanhtao"><a href="http://vtcgame.vn/hoanh"><img src="http://static.vtcgame.vn/header/images/ic_c.gif" title="ChÆ¡i ngay" border="0" /></a><a href="http://vtcgame.vn/hoanh/">HoĂ nh Táº£o ThiĂªn Háº¡</a><div class="clear"></div></div>';
	h_data += '<div class="h_menu_p"  id="satthu"><a href="http://satthu.vtcgame.vn"><img src="http://static.vtcgame.vn/header/images/ic_c.gif" title="ChÆ¡i ngay" border="0" /></a><a href="http://satthu.vtcgame.vn">SĂ¡t Thá»§ Truyá»n Ká»³</a><div class="clear"></div></div>';
	h_data += '<div class="h_menu_p"  id="cotyphu"><a href="http://cotyphu.vtcgame.vn/"><img src="http://static.vtcgame.vn/header/images/ic_c.gif" title="ChÆ¡i ngay" border="0" /></a><a href="http://cotyphu.vtcgame.vn/">Cá» Tá»· PhĂº</a><img width="18" height="7" style="float: right;margin-top: 0px; margin-right: 40px;" src="http://static.vtcgame.vn/header/images/gif-0236.gif"></a><div class="clear"></div></div>';
	


    h_data += '</div>';
	
    h_data += '<div class="h_menu_list_nd"><p>MINIGAME</p>';
	h_data += '<div class="h_menu_p"  id="sieu-cup"><a href="http://vtcgame.vn/kiem-vcoin/sieu-cup/"><img src="http://static.vtcgame.vn/header/images/ic_c.gif" title="ChÆ¡i ngay" border="0" /></a><a href="http://vtcgame.vn/kiem-vcoin/sieu-cup/">SiĂªu cĂºp<img width="18" height="7" style="float: right;margin-top: 0px; margin-right: 40px;" src="http://static.vtcgame.vn/header/images/gif-0236.gif"></a><div class="clear"></div></div>';
    h_data += '<div class="h_menu_p"  id="tam-loc"><a href="http://vtcgame.vn/kiem-vcoin/tam-loc/"><img src="http://static.vtcgame.vn/header/images/ic_c.gif" title="ChÆ¡i ngay" border="0" /></a><a href="http://vtcgame.vn/kiem-vcoin/tam-loc/">Tam lá»™c<img width="18" height="7" style="float: right;margin-top: 0px; margin-right: 40px;" src="http://static.vtcgame.vn/header/images/gif-0236.gif"></a><div class="clear"></div></div>';
    h_data += '<div class="h_menu_p"  id="san-thuong"><a href="http://vtcgame.vn/kiem-vcoin/san-thuong/"><img src="http://static.vtcgame.vn/header/images/ic_c.gif" title="ChÆ¡i ngay" border="0" /></a><a href="http://vtcgame.vn/kiem-vcoin/san-thuong/">SÄƒn thÆ°á»Ÿng<img width="18" height="7" style="float: right;margin-top: 0px; margin-right: 40px;" src="http://static.vtcgame.vn/header/images/gif-0236.gif"></a><div class="clear"></div></div>';
    h_data += '<div class="h_menu_p"  id="that-truyen"><a href="http://vtcgame.vn/kiem-vcoin/that-truyen/?utm_source=conggame&utm_medium=banner&utm_campaign=that-truyen"><img src="http://static.vtcgame.vn/header/images/ic_c.gif" title="ChÆ¡i ngay" border="0" /></a><a href="http://vtcgame.vn/kiem-vcoin/that-truyen/?utm_source=conggame&utm_medium=banner&utm_campaign=that-truyen">Tháº¥t truyá»n<img width="18" height="7" style="float: right;margin-top: 0px; margin-right: 40px;" src="http://static.vtcgame.vn/header/images/gif-0236.gif"></a><div class="clear"></div></div>';
	h_data += '<div class="h_menu_p"  id="thap-nhi-tranh-tai"><a href="http://vtcgame.vn/kiem-vcoin/thap-nhi-tranh-tai/"><img src="http://static.vtcgame.vn/header/images/ic_c.gif" title="ChÆ¡i ngay" border="0" /></a><a href="http://vtcgame.vn/kiem-vcoin/thap-nhi-tranh-tai/">Tháº­p Nhá»‹ Tranh TĂ i</a><div class="clear"></div></div>';
    h_data += '<div class="h_menu_p"  id="vuong-quoc-sao"><a href="http://vtcgame.vn/kiem-vcoin/vuong-quoc-sao/"><img src="http://static.vtcgame.vn/header/images/ic_c.gif" title="ChÆ¡i ngay" border="0" /></a><a href="http://vtcgame.vn/kiem-vcoin/vuong-quoc-sao/">VÆ°Æ¡ng Quá»‘c Sao</a><div class="clear"></div></div>';
    //h_data += '<div class="h_menu_p"  id="lenh-truy-na"><a href="http://vtcgame.vn/kiem-vcoin/lenh-truy-na/"><img src="http://static.vtcgame.vn/header/images/ic_c.gif" title="ChÆ¡i ngay" border="0" /></a><a href="http://vtcgame.vn/kiem-vcoin/lenh-truy-na/">Lá»‡nh Truy NĂ£</a><div class="clear"></div></div>';
    //h_data += '<div class="h_menu_p"  id="ca-kiem"><a href="http://vtcgame.vn/kiem-vcoin/ca-kiem/"><img src="http://static.vtcgame.vn/header/images/ic_c.gif" title="ChÆ¡i ngay" border="0" /></a><a href="http://vtcgame.vn/kiem-vcoin/ca-kiem/">Cà KiĂª̀m</a><div class="clear"></div></div>';
    //h_data += '<div class="h_menu_p"  id="mat-ma-maya"><a href="http://vtcgame.vn/kiem-vcoin/mat-ma-maya/"><img src="http://static.vtcgame.vn/header/images/ic_c.gif" title="ChÆ¡i ngay" border="0" /></a><a href="http://vtcgame.vn/kiem-vcoin/mat-ma-maya/">Máº­t MĂ£ Maya</a><div class="clear"></div></div>';
    h_data += '<div class="h_menu_p"  id="san-ngoc"><a href="http://vtcgame.vn/kiem-vcoin/san-ngoc/"><img src="http://static.vtcgame.vn/header/images/ic_c.gif" title="ChÆ¡i ngay" border="0" /></a><a href="http://vtcgame.vn/kiem-vcoin/san-ngoc/">SÄƒn Ngò£c</a><div class="clear"></div></div>';
    //h_data += '<div class="h_menu_p"  id="luc-coc"><a href="http://vtcgame.vn/kiem-vcoin/luc-coc-dao-tien/"><img src="http://static.vtcgame.vn/header/images/ic_c.gif" title="ChÆ¡i ngay" border="0" /></a><a href="http://vtcgame.vn/kiem-vcoin/luc-coc-dao-tien/">Lá»¥c CĂ´̀c Äà€o TiĂªn</a><div class="clear"></div></div>';
    h_data += '<div class="h_menu_p"  id="nha-may-keo-ngot"><a href="http://vtcgame.vn/kiem-vcoin/keo-ngot/"><img src="http://static.vtcgame.vn/header/images/ic_c.gif" title="ChÆ¡i ngay" border="0" /></a><a href="http://vtcgame.vn/kiem-vcoin/keo-ngot/">NhĂ  MĂ¡y Káº¹o Ngá»t</a><div class="clear"></div></div>';
	
	h_data += '<div class="h_menu_p"  id="dao-mo"><a href="http://vtcgame.vn/kiem-vcoin/dao-mo/"><img src="http://static.vtcgame.vn/header/images/ic_c.gif" title="ChÆ¡i ngay" border="0" /></a><a href="http://vtcgame.vn/kiem-vcoin/dao-mo/">ÄĂ o má»</a><div class="clear"></div></div>';
	//h_data += '<div class="h_menu_p"  id="lat-ngua"><a href="http://latngua.com/"><img src="http://static.vtcgame.vn/header/images/ic_c.gif" title="ChÆ¡i ngay" border="0" /></a><a href="http://latngua.com/">Láº­t ngá»­a</a><div class="clear"></div></div>';
	
	//h_data += '<div class="h_menu_p"  id="bingo"><a href="http://vtcgame.vn/kiem-vcoin/bingo/"><img src="http://static.vtcgame.vn/header/images/ic_c.gif" title="ChÆ¡i ngay" border="0" /></a><a href="http://vtcgame.vn/kiem-vcoin/bingo/">BĂ­ NgĂ´</a><div class="clear"></div></div>';
	
	h_data += '</div>';
    h_data += '<div class="h_menu_list_nd"><p>MOBILE GAME</p>';
    h_data += '<div class="h_menu_p"  id="audition-mobile"><a href="http://am.vtcgame.vn/"><img src="http://static.vtcgame.vn/header/images/ic_c.gif" title="ChÆ¡i ngay" border="0" /></a><a href="http://am.vtcgame.vn/">Au Mobile</a><div class="clear"></div></div>';
	h_data += '<div class="h_menu_p"  id="lolem-mobile"><a href="http://goo.gl/Is6IQb"><img src="http://static.vtcgame.vn/header/images/ic_c.gif" title="ChÆ¡i ngay" border="0" /></a><a href="http://2l.vtcgame.vn/">Lá» lem</a><div class="clear"></div></div>';
    h_data += '<div class="h_menu_p"  id="phi-ma-mobile"><a href="http://goo.gl/5GF3JP"><img src="http://static.vtcgame.vn/header/images/ic_c.gif" title="ChÆ¡i ngay" border="0" /></a><a href="http://goo.gl/5GF3JP">Phi MĂ£</a><div class="clear"></div></div>';
	h_data += '<div class="h_menu_p"  id="temphepthuat-mobile"><a href="http://goo.gl/XF87lU"><img src="http://static.vtcgame.vn/header/images/ic_c.gif" title="ChÆ¡i ngay" border="0" /></a><a href="http://goo.gl/XF87lU">Tem PhĂ©p Thuáº­t</a><div class="clear"></div></div>';
	h_data += '<div class="h_menu_p"  id="cungthu"><a href="https://id.vtc.vn/tin-tuc/chuyen-muc-57/tin-21946/game-moi-co-hoi-nhan-1000-vcoin-cho-xa-thu.html"><img src="http://static.vtcgame.vn/header/images/ic_c.gif" title="ChÆ¡i ngay" border="0" /></a><a href="https://id.vtc.vn/tin-tuc/chuyen-muc-57/tin-21946/game-moi-co-hoi-nhan-1000-vcoin-cho-xa-thu.html">Cung Thá»§</a><div class="clear"></div></div>';
	h_data += '<div class="h_menu_p"  id="san-ngoc-mobile"><a href="https://id.vtc.vn/tin-tuc/chuyen-muc-57/tin-22623/event-tai-app-nhan-50000-vcoin-free-cung-game-san-ngoc.html"><img src="http://static.vtcgame.vn/header/images/ic_c.gif" title="ChÆ¡i ngay" border="0" /></a><a href="https://id.vtc.vn/tin-tuc/chuyen-muc-57/tin-22623/event-tai-app-nhan-50000-vcoin-free-cung-game-san-ngoc.html">SÄƒn ngá»c</a><div class="clear"></div></div>';
    h_data += '</div>';
    h_data += '<div class="clear"></div></div>';
    h_data += '</div>';
    /*End List game*/
    


    //h_data += '<div class="h_menu_list1 cong-dong">';
    //h_data += '<div class="h_menu_list_nd1">';
    
	//h_data += '<a href="' + h_link + '" target="_blank">DIá»„N ÄĂ€N</a>';
    //h_data += '<p>CLAN/CLUB</p>';
    //h_data += '<a href="http://portal-wot.go.vn/uc/clanwars/" target="_blank">WORLD OF TANK</a>';
    //h_data += '<a href="http://cf.vtcgame.vn/clan" target="_blank">Äá»˜T KĂCH</a>';
    //h_data += '<div class="clear"></div>';
    //h_data += '</div>';
    //h_data += '</div>';
    h_data += '<div class="h_menu_list4 gift-code">';
    h_data += '<div class="h_menu_list3">';
    h_data += '<a href="http://vtcgame.vn/gift-code" target="_blank">Sá»­ dá»¥ng Giftcode</a>';
    h_data += '<a href="http://vtcgame.vn/gift-code" target="_blank">Nháº­n Giftcode</a>';
    h_data += '</div></div><div class="h_acc"></div>';

    h_data += '<div class="clear"></div>';
    h_data += '<div class="h_dong1"><marquee scrollamount="3" onmouseover="this.stop()" onmouseout="this.start()" id="contentnotify"></marquee></div>';
    // h_data += '<div class="h_search"><input type="search" placeholder="TĂ¬m kiáº¿m"></div>';
    h_data += '<div class="clear"></div></div>';
    h_data += '<a href="http://vtcgame.vn/"><div style="top: 5px; position: absolute; width: 215px; height: 65px;"></div></a>';
    h_data += '</div></div>';

	    if (window.location.href.indexOf('http://vtcgame.vn/kiem-vcoin/') < 0) {
        h_data += '<div id="mydivvtcmenu"></div>';
    }
    //h_data += '<div class="clear"></div>';
    //h_data += '</div>';
    //h_data += '</div>';
    //h_data += '</div></div>';

    var h_div = document.createElement("div");
    h_div.setAttribute("id", "h_header");
    h_appendBodyChild(h_div);
    $("#h_header").html(h_data);

    loadnotify();

    $(".h_menu_list_nd .h_menu_p").hover(function () {
        $(".h_menu_list_preview div.h_menu_list_t").hide();
        $(".h_menu_list_preview div." + this.id).fadeIn();
    }, function () {
        //$(".h_menu_list_preview div." + this.id).hide();
        //  $(".h_menu_list_preview div.h_menu_list_t").hide();
    });
    $(".h_dong2 a").hover(function () {
        $(".h_dong2 a").each(function () {
            $(this).removeClass();
        });

        $(this).addClass("h_chon");
        if (this.id.length > 0) {
            if (this.id == "game") {
                $(".h_menu_list").show();
                $(".h_menu_list div." + this.id).fadeIn();
            } 
			else if (this.id == "cong-dong") {
                $(".cong-dong").show();
                $(".gift-code").hide();
            } 
			else if (this.id == "gift-code") {
                $(".gift-code").show();
                $(".cong-dong").hide();
            }
        } else {
            $(".h_menu_list").hide();
            $(".h_menu_list1").hide();
            $(".h_menu_list4").hide();
        }
    }, function () {
        $(this).removeClass();

        $(".h_dong2 a").each(function () {

            if (window.location.href.indexOf(this.href) >= 0) $(this).addClass("h_chon");;
        });
    });

    $(".h_dong2 a").click(function () {
        $(".h_dong2 a").each(function () {
            $(this).removeClass();
        });
        $(this).addClass("h_chon");
    });

    $(".h_menu_list").mouseleave(function () {
        $(".h_menu_list").css("display", "none");
    });
    $(".h_menu_list1").mouseleave(function () {
        $(".h_menu_list1").css("display", "none");
    });
    $(".h_menu_list4").mouseleave(function () {
        $(".h_menu_list4").css("display", "none");
    });
    $(".h_acc_down").mouseleave(function () {
        $(".h_acc_down").css("display", "none");
    });

    /*$('#h_search').keydown(function (event) {
        if (event.keyCode == 13)
            window.location.href = 'http://profile.vtcgame.vn/#tim-kiem/' + $('#h_search').val();
    });
    */
console.log('window.location.href' + window.location.href);
	
  // if (window.location.href == 'http://cf.vtcgame.vn/' || 
  // window.location.href =='http://au.vtcgame.vn/' || 
  // window.location.href == 'http://a2.vtcgame.vn/' || 
  // window.location.href == 'http://phidoi.vtcgame.vn/' || 
  // window.location.href == 'http://bongro.vtcgame.vn/' ) {
     
	   // var rickflash_html='<div style="bottom: 0px; right: 0px; margin-bottom: 1px; border: 0px none; position: fixed; z-index: 1100; height: 350px;">';
		    // rickflash_html+='<object ';
		    // rickflash_html+='width="450" height="350"> <param name="wmode" value="transparent" />  <embed src="http://event.vtcgame.vn/menu/images/cf_richmedia.swf" quality="high" type="application/x-shockwave-flash" width="450" height="350" wmode="transparent"  /></object></div>';
		   // $('body').append(rickflash_html);
			
				
    // }
	
	
	
});


$(function () {

    var idleSeconds = 30;
    var idleTimer; idleTimer = 0;
    function resetTimer() {
        clearTimeout(idleTimer);
        idleTimer = setTimeout(whenUserIdle, idleSeconds * 1000);
    }

    $(document.body).bind('mousemove', resetTimer);
    resetTimer(); // Start the timer when the page loads

    function whenUserIdle() {
        //   console.log("idleSeconds");
        if (typeof (localStorage) == "undefined" || userSession == '') return;

        var isIdleLogout = false;

        for (var j = 0; j < mustConfirmPassURL.length; j++) {
            if (window.location.href.indexOf(mustConfirmPassURL[j]) == 0) {
                isIdleLogout = true;
            }
        }

        if (!isIdleLogout) return;

        if (window.localStorage.getItem(userSession) != null) {

            var info = JSON.parse(window.localStorage.getItem(userSession));

            // Is Timeout return
            if (new Date().getTime() - info.time >= idleLogout * 60 ) {
                return;
            }

        }

        // Update last Activetime
        loginInfo.time = new Date().getTime();
        window.localStorage.setItem(userSession, JSON.stringify(loginInfo));

    }

});


if (typeof (ga) == 'undefined') {
    (function (i, s, o, g, r, a, m) {
        i['GoogleAnalyticsObject'] = r; i[r] = i[r] || function () {
            (i[r].q = i[r].q || []).push(arguments)
        }, i[r].l = 1 * new Date(); a = s.createElement(o),
        m = s.getElementsByTagName(o)[0]; a.async = 1; a.src = g; m.parentNode.insertBefore(a, m)
    })(window, document, 'script', '//www.google-analytics.com/analytics.js', 'ga');

}

var GA_UA = 'UA-42370329-1';



if (window.location.href.indexOf('http://vtcgame.vn/kiem-vcoin/tai-loc') >= 0) {
    GA_UA = 'UA-29343718-2';
    ga('create', GA_UA, 'vtcgame.vn');
	ga('require', 'displayfeatures');
    ga('send', 'pageview');   
}

if (window.location.href.indexOf('http://vtcgame.vn/kiem-vcoin/vuong-quoc-sao') >= 0) {
    GA_UA = 'UA-29343718-3';
    ga('create', GA_UA, 'vtcgame.vn');
	ga('require', 'displayfeatures');
    ga('send', 'pageview');   
}
 
if (window.location.href.indexOf('http://vtcgame.vn/kiem-vcoin/lenh-truy-na') >= 0) {
    GA_UA = 'UA-29343718-4';
    ga('create', GA_UA, 'vtcgame.vn');
	ga('require', 'displayfeatures');
    ga('send', 'pageview');   
}

if (window.location.href.indexOf('http://vtcgame.vn/kiem-vcoin/ca-kiem') >= 0) {
    GA_UA = 'UA-29343718-5';
    ga('create', GA_UA, 'vtcgame.vn');
	ga('require', 'displayfeatures');
    ga('send', 'pageview');   
}

if (window.location.href.indexOf('http://vtcgame.vn/kiem-vcoin/mat-ma-maya') >= 0) {
    GA_UA = 'UA-29343718-6';
    ga('create', GA_UA, 'vtcgame.vn');
	ga('require', 'displayfeatures');
    ga('send', 'pageview');   
}

if (window.location.href.indexOf('http://vtcgame.vn/kiem-vcoin/san-ngoc') >= 0) {
    GA_UA = 'UA-29343718-7';
    ga('create', GA_UA, 'vtcgame.vn');
	ga('require', 'displayfeatures');
    ga('send', 'pageview');   
}

if (window.location.href.indexOf('http://vtcgame.vn/kiem-vcoin/keo-ngot') >= 0) {
    GA_UA = 'UA-29343718-10';
    ga('create', GA_UA, 'vtcgame.vn');
	ga('require', 'displayfeatures');
    ga('send', 'pageview');   
}

if (window.location.href.indexOf('http://vtcgame.vn/kiem-vcoin/thap-nhi-tranh-tai') >= 0) {
    GA_UA = 'UA-29343718-1';
    ga('create', GA_UA, 'vtcgame.vn');
	ga('require', 'displayfeatures');
    ga('send', 'pageview');   
}


if (window.location.href.indexOf('http://vtcgame.vn/kiem-vcoin/tan-xuan-phat-loc/') >= 0) {
    GA_UA = 'UA-29343718-13';   
    ga('create', GA_UA, 'vtcgame.vn');
	ga('require', 'displayfeatures');
    ga('send', 'pageview');
}

if (window.location.href.indexOf('http://vtcgame.vn/kiem-vcoin/cho-tet/') >= 0) {
    GA_UA = 'UA-29343718-15';   
    ga('create', GA_UA, 'vtcgame.vn');
	ga('require', 'displayfeatures');
    ga('send', 'pageview');
}

if (window.location.href.indexOf('http://vtcgame.vn/kiem-vcoin/li-xi-phat-loc/') >= 0) {
    GA_UA = 'UA-29343718-14';   
    ga('create', GA_UA, 'vtcgame.vn');
	ga('require', 'displayfeatures');
    ga('send', 'pageview');
}

if (window.location.href.indexOf('http://vtcgame.vn/kiem-vcoin/dao-mo/') >= 0) {
    GA_UA = 'UA-29343718-16';   
    ga('create', GA_UA, 'vtcgame.vn');
	ga('require', 'displayfeatures');
    ga('send', 'pageview');
}


if (window.location.href.indexOf('http://a2.vtcgame.vn') >= 0) {
    GA_UA = 'UA-42370329-7';
    ga('create', GA_UA, 'vtcgame.vn');
	ga('require', 'displayfeatures');
    ga('send', 'pageview');   
}

if (window.location.href.indexOf('http://au.vtcgame.vn') >= 0) {
    GA_UA = 'UA-42370329-6';
    ga('create', GA_UA, 'vtcgame.vn');
	ga('require', 'displayfeatures');
    ga('send', 'pageview');   
}

if (window.location.href.indexOf('http://au.go.vn') >= 0) {
    GA_UA = 'UA-42370329-6';
    ga('create', GA_UA, 'vtcgame.vn');
	ga('require', 'displayfeatures');
    ga('send', 'pageview');   
}

if (window.location.href.indexOf('http://bongro.vtcgame.vn') >= 0) {
    GA_UA = 'UA-42370329-10';
    ga('create', GA_UA, 'vtcgame.vn');
	ga('require', 'displayfeatures');
    ga('send', 'pageview');   
}

if (window.location.href.indexOf('http://cl.vtcgame.vn') >= 0) {
    GA_UA = 'UA-42370329-3';
    ga('create', GA_UA, 'vtcgame.vn');
	ga('require', 'displayfeatures');
    ga('send', 'pageview');   
}

if (window.location.href.indexOf('http://cf.vtcgame.vn/quatang') >= 0) {
	GA_UA = 'UA-46057210-21';   
    ga('create', GA_UA, 'vtcgame.vn');	
	ga('require', 'displayfeatures');
	ga('send', 'pageview');
}

if (window.location.href.indexOf('http://cf.vtcgame.vn/ngayvang') >= 0) {
	GA_UA = 'UA-46057210-20';   
    ga('create', GA_UA, 'vtcgame.vn');	
	ga('require', 'displayfeatures');
	ga('send', 'pageview');
}

if (window.location.href.indexOf('cf.vtcgame.vn') >= 0) {

    GA_UA = 'UA-42370329-5';
    ga('create', GA_UA, 'vtcgame.vn');
	ga('require', 'displayfeatures');
    ga('send', 'pageview');
}

if (window.location.href.indexOf('cf.go.vn') >= 0) {
    GA_UA = 'UA-42370329-5';
    ga('create', GA_UA, 'vtcgame.vn');
	ga('require', 'displayfeatures');
    ga('send', 'pageview');
}


if (window.location.href.indexOf('http://phidoi.vtcgame.vn') >= 0) {
    GA_UA = 'UA-42370329-8';
    ga('create', GA_UA, 'vtcgame.vn');
	ga('require', 'displayfeatures');
    ga('send', 'pageview');
}

if (window.location.href.indexOf('http://wot.vtcgame.vn') >= 0) {
    GA_UA = 'UA-42370329-9';
    ga('create', GA_UA, 'vtcgame.vn');
	ga('require', 'displayfeatures');
    ga('send', 'pageview');
}


if (window.location.href.indexOf('http://hc.vtcgame.vn') >= 0) {
    GA_UA = 'UA-42370329-42';
    ga('create', GA_UA, 'vtcgame.vn');
	ga('require', 'displayfeatures');
    ga('send', 'pageview');
}
 
 
if (window.location.href.indexOf('http://cmo.vtcgame.vn') >= 0) {
    GA_UA = 'UA-42370329-12';   
    ga('create', GA_UA, 'vtcgame.vn');
	ga('require', 'displayfeatures');
    ga('send', 'pageview');
}

if (window.location.href.indexOf('http://cqt.vtcgame.vn') >= 0) {
    GA_UA = 'UA-46057210-10';   
    ga('create', GA_UA, 'vtcgame.vn');
	ga('require', 'displayfeatures');
    ga('send', 'pageview');
}

if (window.location.href.indexOf('http://diendan.vtcgame.vn') >= 0) {
    GA_UA = 'UA-42370329-15';   
    ga('create', GA_UA, 'vtcgame.vn');
	ga('require', 'displayfeatures');
    ga('send', 'pageview');
}

/*
if (window.location.href.indexOf('http://cf.vtcgame.vn/') >= 0 ||
window.location.href.indexOf('http://au.vtcgame.vn/') >= 0 ||
window.location.href.indexOf('http://cl.vtcgame.vn/') >= 0 ||
window.location.href.indexOf('http://bongro.vtcgame.vn/') >= 0)
{
	window.open(
	  'http://gianghoky.vn/landing3/',
	  '_new' // <- This is what makes it open in a new window.
	);
}*/



//if (window.location.href.indexOf('http://diendan.vtcgame.vn') >= 0 ||
//
//	window.location.href.indexOf('forumdisplay.php?241-Dot-Kich-Trong-tam-ngam') >= 0 ||
//	window.location.href.indexOf('86-Cho-game') >= 0 
//	) {
	//window.location.href = 'http://ghk.vtcgame.vn/'
	//window.open(
	 // 'http://gianghoky.vn/',
	 // '_new' // <- This is what makes it open in a new window.
	//);
	
//}

if (window.location.href.indexOf('http://vtcgame.vn/hoanh') >= 0) {
    GA_UA = 'UA-42370329-31';   
    ga('create', GA_UA, 'vtcgame.vn');
	ga('require', 'displayfeatures');
    ga('send', 'pageview');
}

if (window.location.href.indexOf('http://ghk.vtcgame.vn/') >= 0) {
    GA_UA = 'UA-42370329-37';   
    ga('create', GA_UA, 'vtcgame.vn');
	ga('require', 'displayfeatures');
    ga('send', 'pageview');
}

if (window.location.href.indexOf('http://vtcgame.vn/kiem-vcoin/bingo/') >= 0) {
    GA_UA = 'UA-29343718-18';   
    ga('create', GA_UA, 'vtcgame.vn');
	ga('require', 'displayfeatures');
    ga('send', 'pageview');
}


if (window.location.href.indexOf('http://vtcgame.vn/kiem-vcoin/sieu-cup/') >= 0) {
    GA_UA = 'UA-29343718-23';   
    ga('create', GA_UA, 'vtcgame.vn');
	ga('require', 'displayfeatures');
    ga('send', 'pageview');
}

if (window.location.href.indexOf('http://vtcgame.vn/kiem-vcoin/tam-loc/') >= 0) {
    GA_UA = 'UA-29343718-22';   
    ga('create', GA_UA, 'vtcgame.vn');
	ga('require', 'displayfeatures');
    ga('send', 'pageview');
}

if (window.location.href.indexOf('http://vtcgame.vn/kiem-vcoin/san-thuong/') >= 0) {
    GA_UA = 'UA-29343718-21';  
    ga('create', GA_UA, 'auto');
	ga('require', 'displayfeatures');
    ga('send', 'pageview');
}



if (window.location.href.indexOf('diendan.game.go.vn') >= 0) {
    ga('create', 'UA-42370329-15', 'go.vn');
	ga('require', 'displayfeatures');
	ga('send', 'pageview');
}

if (window.location.href.indexOf('vtcgame.vn/kiem-vcoin/gioi-thieu/index.html') >= 0) {
 var inforSession = readCookieSession("ssoinfo");
if( typeof (inforSession) != "undefined" && inforSession != "") 
{
 // ga('create', 'UA-42370329-24', 'vtcgame.vn');
  ga('create', 'UA-42370329-24', {
  'storage': 'none',
  'clientId': inforSession //'35009a79-1a05-49d7-b876-2b884d0f825b'
});
ga('require', 'displayfeatures');
  ga('send', 'pageview');
}
}




if (window.location.href.indexOf('http://vtcgame.vn/kiem-vcoin/ngoi-sao-san-co') >= 0) {
 GA_UA = 'UA-42370329-40';   
    ga('create', GA_UA, 'vtcgame.vn');	
 ga('require', 'displayfeatures');
  ga('send', 'pageview');

}


if (window.location.href.indexOf('http://vtcgame.vn/kiem-vcoin/tam-loc') >= 0) {
 GA_UA = 'UA-29343718-22';   
    ga('create', GA_UA, 'vtcgame.vn');	
	ga('require', 'displayfeatures');
	ga('send', 'pageview');
}








 
ga('create', GA_UA, 'vtcgame.vn');
ga('require', 'displayfeatures');
ga('send', 'pageview');



  //ga('create', 'UA-46909752-1', 'vtcgame.vn');
  //ga('send', 'pageview');

 

/*

if (window.location.href == 'http://vtcgame.vn/' ||
	//window.location.href == 'http://au.vtcgame.vn/' ||
	window.location.href.indexOf('au.vtcgame.vn/') > 0 ||
	window.location.href.indexOf('a2.vtcgame.vn/') > 0 ||
	window.location.href.indexOf('cf.vtcgame.vn/') > 0 ||
	window.location.href.indexOf('phidoi.vtcgame.vn/') > 0 ||
	window.location.href.indexOf('bongro.vtcgame.vn/') > 0 ||
	window.location.href.indexOf('ghk.vtcgame.vn') > 0 ||
	window.location.href.indexOf('vtcgame.vn/hoanh/') > 0 ||
	window.location.href.indexOf('hc.vtcgame.vn/') > 0) {
	
	var allowRedirect = false;
	var allowPopupAndroid = false;
	if (!allowRedirect && typeof (window.localStorage) != 'undefined' && /Android/i.test(navigator.userAgent)) {
    var key = 'gmo-tienhiep-android-popup';
    var data = window.localStorage.getItem(key);
    if (data != null && data != '') {
        data = JSON.parse(data);
        if (data.time != null && data.days != null) {
            var now = (new Date()).getTime();
            if (now - data.time > data.days * 1 * 20 * 1000) {
                window.localStorage.setItem(key, JSON.stringify({ time: (new Date()).getTime(), days: 1 }));
                allowPopupAndroid = true;
            }
        }
    } else {
        try {
            window.localStorage.setItem(key, JSON.stringify({ time: (new Date()).getTime(), days: 1 }));
            allowPopupAndroid = true;
        } catch (e) {
        }
    }
}
var allowPopupiPhone = false;
console.log(navigator.userAgent);
if (!allowRedirect && typeof (window.localStorage) != 'undefined' && /iPhone|iPod|iPad|iOs/i.test(navigator.userAgent)) {
    var key = 'gmo-tienhiep-ios-popup';
    var data = window.localStorage.getItem(key);
    if (data != null && data != '') {
        data = JSON.parse(data);
        if (data.time != null && data.days != null) {
            var now = (new Date()).getTime();
            if (now - data.time > data.days * 1 * 20 * 1000) {
                window.localStorage.setItem(key, JSON.stringify({ time: (new Date()).getTime(), days: 1 }));
                allowPopupiPhone = true;
            }
        }
    } else {
        try {
            window.localStorage.setItem(key, JSON.stringify({ time: (new Date()).getTime(), days: 1 }));
            allowPopupiPhone = true;
        } catch (e) {
        }
    }
}

var GA_UID = 'UA-42370329-30';
if (allowPopupAndroid) {
    setTimeout(function () { if (confirm("TiĂªn Hiá»‡p Ká»³ DuyĂªn â€“ Game Mobile vá»›i Ä‘á»“ há»a cá»±c Ä‘áº¹p, game play Ä‘á»™c Ä‘Ă¡o. HoĂ n toĂ n miá»…n phĂ­ & HOT nháº¥t 2014. Báº¥m OK Ä‘á»ƒ táº£i ngay.")) { ga('create', 'GA_UID', 'vtcgame.vn'); ga('send', 'event', 'Tienhiep-android.vn', 'DownLoad', 'DownLoad Click'); trackingServer(GA_UID); setTimeout(function () { top.location.replace("https://play.google.com/store/apps/details?id=com.uuzu.xxlmandroid"); }, 5000); } }, 2000);
}
if (allowPopupiPhone) {
    setTimeout(function () { if (confirm("TiĂªn Hiá»‡p Ká»³ DuyĂªn â€“ Game Mobile vá»›i Ä‘á»“ há»a cá»±c Ä‘áº¹p, game play Ä‘á»™c Ä‘Ă¡o. HoĂ n toĂ n miá»…n phĂ­ & HOT nháº¥t 2014. Báº¥m OK Ä‘á»ƒ táº£i ngay.")) { ga('create', 'GA_UID', 'vtcgame.vn'); ga('send', 'event', 'Tienhiep-iOS.vn', 'DownLoad', 'DownLoad Click'); trackingServer(GA_UID); setTimeout(function () { top.location.replace("http://dlmobile.vtcgame.vn/tienhiep1.html"); }, 5000); } }, 2000);
}

function trackingServer(GA_UID) {
    try{
        var utm_source = getParameterByName('utm_source'); //document.referrer != '' ? document.referrer : top.document.location.href;
        var utm_medium = getParameterByName('utm_medium'); //document.referrer != '' ? document.referrer : 'default';
		var utm_campaign = getParameterByName('utm_campaign');
        var userAgent = navigator.userAgent;
        var referUrl = top.document.location.href;
        var ip = '';
        var dataJSON = {
            GACode: GA_UID,
            Url: 'http://tienhiep.vtcgame.vn/',
            category: 'Download Click',
            action: 'Download Click',
            label: 'Download Click',
            service_id: 191919,
            headers: userAgent,
            value: '0',
            ip: '',
            accountName: 'UNLOGIN',
            accountId: '0',
            amount: 0,
            referUrl: referUrl,
            cookies: '',
            queueActions: '',
            utm_source: utm_source,
            utm_medium: 'popup',
            utm_term: 'default',
            utm_content: 'default',
            utm_campaign: utm_campaign
        };
        var url = 'https://id.vtc.vn/tracking/api/Analytics/trackingEvent';
        $.ajax({
            type: "GET",
            url: url,
            data: dataJSON,
            success: function (mes) { console.log(mes); }
        });
    } catch (mes) { console.log(mes); }
}

function getParameterByName(name) {
    name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
    var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
        results = regex.exec(location.search);
    return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
}



	
}*/